package com.jzo2o.health.service.impl;

import com.jzo2o.health.mapper.ReservationSettingMapper;
import com.jzo2o.health.model.dto.request.ReservationSettingUpsertReqDTO;
import com.jzo2o.health.model.dto.response.ReservationDateResDTO;
import com.jzo2o.health.model.dto.response.ReservationSettingResDTO;
import com.jzo2o.health.model.excel.ReservationImportData;
import com.jzo2o.health.service.IReservationSettingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: beiqian
 * @Date: 2024-07-29 13:12
 * @Description:
 */
@Service
public class IReservationSettingServiceImpl implements IReservationSettingService {

    @Resource
    ReservationSettingMapper reservationSettingMapper;
    /**
     * 按月查询预约
     * @param date 日期
     * @return
     */
    @Override
    public List<ReservationSettingResDTO> getReservationSettingByMonth(String date) {
        return reservationSettingMapper.getReservationSettingByMonth(date + "%");
    }

    @Override
    public void editNumberByDate(ReservationSettingUpsertReqDTO reservationSettingUpsertReqDTO) {
        reservationSettingMapper.editNumberByDate(reservationSettingUpsertReqDTO.getOrderDate().toString(), reservationSettingUpsertReqDTO.getNumber());
    }

    @Override
    public void upload(List<ReservationImportData> reservationImportDataList) {
        reservationImportDataList.forEach(item ->{
            reservationSettingMapper.upload(item.getDate().toString(), item.getNumber());
        });

    }

    @Override
    public ReservationDateResDTO getReservationDateByMonth(String month) {
        List<String> reservationDateByMonth = reservationSettingMapper.getReservationDateByMonth(month);
        return new ReservationDateResDTO(reservationDateByMonth);
    }


}
